﻿using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace mvcForum.Web {

	public class ForumRouteRegistration {

		public void RegisterRoutes(RouteCollection routes) {	}

		public void RegisterRoutes(AreaRegistrationContext context) {
			// Route for showing a particular topic.
			context.MapRoute("ShowTopic", "forum/viewtopic/{title}/{id}/{additional}", new { area = "forum", controller = "Topic", action = "Index", additional = UrlParameter.Optional });
			// Route for showing a particular category.
			context.MapRoute("ShowCategory", "forum/viewcategory/{title}/{id}", new { area = "forum", controller = "Category", action = "Index" });
			// Route for showing a particular user.
			context.MapRoute("ShowProfile", "forum/viewprofile/{id}/{name}", new { area = "forum", controller = "Profile", action = "Index", id = UrlParameter.Optional });
			// Route for the "no access" page.
			context.MapRoute("NoAccess", "forum/noaccess", new { area = "forum", controller = "NoAccess", action = "Index" });
			// Route for showing a particular forum.
			context.MapRoute("ShowForum", "forum/viewforum/{title}/{id}", new { area = "forum", controller = "Forum", action = "Index" });

			// Default route for the area.
			context.MapRoute(
				"Forum_default",
				"forum/{controller}/{action}/{id}",
				new {
					area = "forum",
					controller = "home",
					action = "index",
					id = UrlParameter.Optional
				},
				new String[] { "mvcForum.Web.Areas.Forum.Controllers" }
			);
		}
	}
}